Improve CLI search output formatting and update docs#121
Merged
TianqiZhang merged 2 commits intoMar 12, 2026
Conversation
Collaborator
TianqiZhang
commented
Mar 12, 2026
- Add formatters for search and code-search results: each result is displayed on its own numbered block instead of a raw JSON blob
- Handle real MCP response fields (description, codeSnippet, link) and clean embedded metadata from code-search descriptions
- Add --json flag to search and code-search for raw JSON piping
- Update docs to reflect published npm package (@microsoft/learn-cli)
- Rename 'Companion CLI' to 'Microsoft Learn CLI' across the repo
- Add formatters for search and code-search results: each result is displayed on its own numbered block instead of a raw JSON blob - Handle real MCP response fields (description, codeSnippet, link) and clean embedded metadata from code-search descriptions - Add --json flag to search and code-search for raw JSON piping - Update docs to reflect published npm package (@microsoft/learn-cli) - Rename 'Companion CLI' to 'Microsoft Learn CLI' across the repo Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Improve CLI search/code-search UX by formatting results into readable numbered blocks (with optional raw JSON output) and update repository/docs branding to “Microsoft Learn CLI” and the published npm package name.
Changes:
- Added result formatters for
searchandcode-search, plus--jsonflag to output raw JSON. - Added unit tests for formatting behavior and updated CLI command tests to validate formatted output /
--json. - Updated documentation and descriptions to reflect
@microsoft/learn-cliand “Microsoft Learn CLI” naming.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/validate-repo.ps1 | Updates validation script wording from “Companion CLI” to “CLI”. |
| cli/src/formatters/search-results.ts | Introduces shared formatter logic for docs/code search outputs. |
| cli/src/commands/search.ts | Adds --json option and formatted output for doc search. |
| cli/src/commands/code-search.ts | Adds --json option and formatted output for code search. |
| cli/src/index.ts | Updates CLI description text. |
| cli/package.json | Updates package description text. |
| cli/test/unit/search-results.test.ts | Adds unit tests for search/code-search formatting. |
| cli/test/unit/cli.test.ts | Updates CLI tests for formatted output and --json behavior. |
| cli/README.md | Updates installation/usage docs and documents --json. |
| README.md | Updates root docs to reference @microsoft/learn-cli and new usage examples. |
Comments suppressed due to low confidence (1)
cli/README.md:1
- The command summary suggests
code-searchalways requires--language <name>, but the CLI option is optional (and now also supports--json). To avoid confusing users, update the synopsis lines to reflect optional flags (e.g.,code-search <query> [--language <name>] [--json]andsearch <query> [--json]).
# Microsoft Learn CLI
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Split formatSingleResult into formatDocsSearchResult and formatCodeSearchResult so code-search-specific cleanup (description metadata stripping, language suffix) does not apply to docs search - Make metadata regex patterns tolerate optional whitespace after colons and optional leading whitespace before keys Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
partychen
approved these changes
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.